package smartcarpool.ui;

import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.os.Bundle;
import android.text.format.Time;
import android.widget.EditText;

import java.util.Calendar;
import java.text.DateFormat;

public class TimePickDialog extends DialogFragment implements OnTimeSetListener {

	private EditText textLine;
	
	public TimePickDialog(EditText tl) {
		super();
		this.textLine = tl;
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		// Use the current time as the default values for the picker
		final Calendar c = Calendar.getInstance();
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minute = c.get(Calendar.MINUTE);

		// Create a new instance of TimePickerDialog and return it
		return new TimePickerDialog(getActivity(), this, hour, minute, true);
	}

	@Override
	public void onTimeSet(android.widget.TimePicker arg0, int hour, int minute) {
		this.textLine.setText(String.format("%02d:%02d", hour,minute));
	}

}
